package cs4game;

public class BoundingBox {
	//Used for (very basic) collision detection between entities
	
	public float xMin, yMin, zMin, xMax,yMax, zMax;	
	public BoundingBox(float xMn, float xMx, float yMn, float yMx, float zMn, float zMx){
		xMin = xMn;
		yMin = yMn;
		zMin = zMn;
		xMax = xMx;
		yMax = yMx;
		zMax = zMx;
	}
	
	public BoundingBox(Vector3D min, Vector3D max){
		this(min.x, max.x, min.y, max.y, min.z, max.z);
	}
	
	//Algorithm to determine  whether or not two blocks are intersecting based on their bounds
	public boolean intersects(BoundingBox box2){
		boolean intersects =  xMin < box2.xMax && xMax > box2.xMin && yMin < box2.yMax && yMax > box2.yMin 
				&& zMin < box2.zMax && zMax > box2.zMin;
		return intersects;
	}
	
	public String toString(){
		return "(("+xMin+", "+xMax+") ("+yMin+", "+yMax+") ("+zMin+", "+zMax+"))";
	}
	
	public void draw(){
		Vector3D p1 = new Vector3D(xMin, yMin, zMin);
		Vector3D p2 = new Vector3D(xMax, yMax, zMax);
		//RectPrism prism = new RectPrism(p1, p2, MainStage.hello1);
		//prism.draw();
	}

	public BoundingBox shifted(Vector3D pos) {
		return new BoundingBox(xMin+pos.x, xMax+pos.x, yMin+pos.y, yMax+pos.y, zMin+pos.z, zMax+pos.z);
	}
	
	
}
